<!--master-->
<table>
	<caption>
		<label for="recordType"><g:message code="b2b.salesOrder.recordType" default="Record Type" /></label>:
		${salesOrderInstance?.recordType?.encodeAsHTML()}
		<g:hiddenField name="recordType.id" value="${salesOrderInstance?.recordType?.id}" />
	</caption>
	<tbody>
        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.dealer" default="Dealer" /></td>
            <td  class="value">${salesOrderInstance?.dealer?.encodeAsHTML()}</td>
            <td  class="name"><g:message code="b2b.salesOrder.department" default="Department" /></td>
            <td  class="value">${salesOrderInstance?.dealer?.department?.encodeAsHTML()}</td>
            <td  class="name"><g:message code="b2b.salesOrder.orderDate" default="Order Date" /></td>
            <td  class="value"><g:formatDate format="yyyy-MM-dd" date="${salesOrderInstance?.orderDate}" /></td>
        </tr>
        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.industry" default="Industry" /></td>
            <td  class="value"><g:link controller="channel" action="show" id="${salesOrderInstance?.industry?.id}">${salesOrderInstance?.industry?.encodeAsHTML()}</g:link></td>
            <td class="name"><g:message code="b2b.salesOrder.project" default="Project" /></td>
            <td  class="value">${fieldValue(bean: salesOrderInstance, field: "project")}</td>
            <td  class="name"><g:message code="b2b.salesOrder.effectiveDate" default="Effective Date" /></td>
            <td  class="value"><g:formatDate format="yyyy-MM-dd" date="${salesOrderInstance?.effectiveDate}" /></td>
        </tr>
        
        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.id" default="Id" /></td>
            <td  class="value">${fieldValue(bean: salesOrderInstance, field: "id")}</td>
            <td  class="name"><g:message code="b2b.salesOrder.serialNumber" default="ERP Order Number" /></td>
            <td  class="value">${fieldValue(bean: salesOrderInstance, field: "serialNumber")}</td>
            <td  class="name"><g:message code="b2b.salesOrder.accountSerialNumber" default="Account Order Number" /></td>
            <td  class="value">${fieldValue(bean: salesOrderInstance, field: "accountSerialNumber")}</td>
        </tr>
        
        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.salesMan" default="Sales Man" /></td>
            <td  class="value"><g:link controller="staff" action="show" id="${salesOrderInstance?.salesMan?.id}">${salesOrderInstance?.salesMan?.encodeAsHTML()}</g:link></td>
            <td class="name"><g:message code="b2b.salesOrder.status" default="Status" /></td>
            <td class="value">${fieldValue(bean: salesOrderInstance, field: "status")}</td>
            <td class="name">&nbsp;</td>
            <td class="value">&nbsp;</td>
        </tr>

        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.address1.label" default="Address(1)" /></td>            
            <td  class="value" colspan="7">${salesOrderInstance?.address1?.encodeAsHTML()}</td>
        </tr>

        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.address2.label" default="Address(2)" /></td>            
            <td  class="value" colspan="7">${salesOrderInstance?.address2?.encodeAsHTML()}</td>
        </tr>

        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.description" default="Desc" /></td>
            <td  class="value" colspan="7">${fieldValue(bean: salesOrderInstance, field: "description")}</td>
        </tr>
        
        <tr class="prop">
            <td  class="name"><g:message code="b2b.salesOrder.owner" default="Owner" /></td>
            <td  class="value"><g:link controller="user" action="show" id="${salesOrderInstance?.owner?.id}">${salesOrderInstance?.owner?.encodeAsHTML()}</g:link></td>
            <td class="name"><g:message code="b2b.salesOrder.createdBy" default="Created By" /></td>
            <td class="value">${fieldValue(bean: salesOrderInstance, field: "createdBy")},${fieldValue(bean: salesOrderInstance, field: "dateCreated")}</td>
            <td class="name"><g:message code="b2b.salesOrder.lastModifiedBy" default="Last Modified By" /></td>
            <td class="value">${fieldValue(bean: salesOrderInstance, field: "lastModifiedBy")},${fieldValue(bean: salesOrderInstance, field: "lastUpdated")}</td>
        </tr>
        
    </tbody>
</table>
<!--end master-->
<!--detail-->
<table>
    <thead>
        <tr>
            <th><g:message code="b2b.salesOrderDetail.serialNumber" default="Serial Number" /></th>
            <th><g:message code="b2b.salesOrderDetail.product" default="Product" /></th>
            <th><g:message code="b2b.product.name" default="Product Name" /></th>
            <th><g:message code="b2b.product.standard" default="Standard" /></th>
            <th><g:message code="b2b.product.category" default="Category" /></th>
            <th><g:message code="b2b.salesOrderDetail.price" default="Price" /></th>
            <th><g:message code="b2b.salesOrderDetail.discount" default="Discount" /></th>
            <th><g:message code="b2b.salesOrderDetail.quantity" default="Order Quantity" /></th>
            <th><g:message code="b2b.salesOrderDetail.deliveryLimitation" default="Delivery Limitation" /></th>
            <th><g:message code="b2b.salesOrderDetail.amount" default="Amount" /></th>
        </tr>
    </thead>
    <tbody id="salesOrderDetailList">
    <g:each in="${salesOrderInstance.salesOrderDetails}" status="i" var="salesOrderDetailInstance">    
        <tr class="prop ${(i % 2) == 0 ? 'odd' : 'even'} " childs="${salesOrderDetailInstance?.serialNumber}">
            <td>
           		${fieldValue(bean: salesOrderDetailInstance, field: "serialNumber")}
            </td>
            <td>${fieldValue(bean: salesOrderDetailInstance, field: "product")}</td>
            <td>${fieldValue(bean: salesOrderDetailInstance, field: "product.name")}</td>
            <td>${fieldValue(bean: salesOrderDetailInstance, field: "product.standard")}</td>
            <td>${include(controller : 'salesOrderAjax', action : 'productCategoryOfCG', params : [product : salesOrderDetailInstance?.product?.serialNumber] )}</td>
            <td class="number"><g:formatNumber number="${salesOrderDetailInstance?.price}" format="###,##0.000000" /></td>
            <td class="number"><g:formatNumber number="${salesOrderDetailInstance?.discount}" format="###,##0.00%" /></td>
            <td class="number"><g:formatNumber number="${salesOrderDetailInstance?.quantity}" format="###,##0.00" /></td>
            <td><g:formatDate format="yyyy-MM-dd" date="${salesOrderDetailInstance?.deliveryLimitation}"/></td>
            <td class="number"><g:formatNumber number="${salesOrderDetailInstance?.amount}" format="###,##0.0000" /></td>
        </tr>
    </g:each>
	</tbody>
	<tfoot>
        <tr>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>&nbsp;</td>
            <td>
            	<label for="totalAmount"><g:message code="b2b.salesOrder.salesOrderDetails.amount.sum" default="Total Amount" /></label>
            </td>
            <td class="number" id="totalAmount">
				${formatNumber(number:salesOrderInstance?.salesOrderDetails*.amount?.sum(), format:'###,##0.0000') }
            </td>
        </tr>
    </tfoot>
</table>
<!--end detail-->
